﻿using System.Runtime.CompilerServices;
using System.Windows;
using KinonekoSoftware.Platform.Windows;

namespace KinonekoSoftware.Studio.ViewModels
{
    /// <summary>
    /// <see cref="TabViewModelSub"/> 类型用于实现全部
    /// </summary>
    public abstract class TabViewModelSub : TabViewModel
    {
        protected TabViewModelSub()
        {
            SnapshotCommand = CreateCommand(DoSnapshotCommand);
        }
        
        
        private void DoSnapshotCommand()
        {
            Core.Snapshot(null);
        }
        
        #region MessageQueues

        internal void SetQueue(IMessageBus<MessageCore> queue) => Queue ??= queue;

        /// <summary>
        /// 
        /// </summary>
        protected IMessageBus<MessageCore> Queue { get; private set; }

        #endregion

        internal void SetCommand(MessageCore msg)
        {
            // TODO:
        }

        protected virtual void OnMessageReceiving(MessageCore msg)
        {
            
        }

        public void Snapshot(Action<object> snapshotCallback)
        {
            Snapshot(new SnapshotMessage{Callback = snapshotCallback});
        }
        
        public void Snapshot(SnapshotMessage message)
        {
            PushToView(message);
        }

        public TabViewModelCore Core            { get; internal set; }
        public ICommandEX       SnapshotCommand { get; }
    }
}